package cn.yunwei.module.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wangbinggui
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    private final RequestHeaderInterceptor requestHeaderInterceptor;

    public WebConfig(RequestHeaderInterceptor requestHeaderInterceptor) {
        this.requestHeaderInterceptor = requestHeaderInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestHeaderInterceptor)
                .addPathPatterns("/admin-api/**") // 只拦截 `admin-api` 下的接口
                .excludePathPatterns("/admin-api/auth/login"); // 登录接口不拦截
    }
}
